# coding=utf-8
##
## Author: jmdvirus@aliyun.com
##
## Create: 2019年02月14日 星期四 16时42分59秒
##
import mxnet as mx

n_filter = 128
net = mx.symbol.Variable('data')
net = mx.sym.Convolution(net, name="convPRE", kernel=(3,3),
        pad=(1,1), num_filter=n_filter)

for i in range(0, 6):
    identity = net
    net = mx.sym.BatchNorm(net, name='bnA' + str(i), fix_gamma = False)
    net = mx.sym.Activation(net, name='actA' + str(i), act_type = 'relu')
    net = mx.sym.Convolution(net, name='convA' + str(i), kernel=(3,3), 
            pad=(1,1), num_filter=n_filter)
    net = mx.sym.BatchNorm(net, name='bnB'+str(i), fix_gamma=False)
    net = mx.sym.Activation(net, name='actB'+str(i), act_type = 'relu')
    net = mx.sym.Convolution(net, name='convB'+str(i), kernel=(3,3),
            pad=(1,1), num_filter = n_filter)

    net = net + identity

net = mx.sym.BatchNorm(net, name='bnFINAL', fix_gamma=False)
net = mx.sym.Activation(net, name='actFINAL', act_type = 'relu')
net = mx.sym.Convolution(net, name='convFINAL', kernel=(1,1),
        num_filter = 1)
net = mx.sym.Flatten(net)

net = mx.sym.SoftmaxOutput(net, name='softmax')

shape = {"data": (32, 8, 19, 19) }
mx.viz.print_summary(symbol=net, shape= shape)
mx.viz.plot_network(symbol=net, shape=shape).view()

